<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <title></title>
	<link rel="stylesheet" type="text/css" href="../css/index.css"/>
	<script src="../js/ajax.js" type="text/javascript" charset="utf-8"></script>
	<script src="../js/vue.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="../js/vant.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="html5plus://ready"></script>		
	<script src="../js/back.js" type="text/javascript" charset="utf-8"></script>
    <style type="text/css">
    	#header{
			text-align: center;			
		}
		#img-div{			
			margin-top: 70px;
			margin-left: -23%;
		}
		#img{			
			width: 50px; 
			height: 50px;			
		}
		#test-div{			
			padding: 0px 30px 0px 30px;
			margin-top: 30px;		
		}
		#pws-div{			
			padding: 0px 30px 0px 30px;
			margin-top: 15px;
			margin-bottom: 40px;
		}
		#text{
			width: 100%;
			background-color: #E8E8E8;			
			height: 45px;
			border: 0px solid;
			border-radius: 40px;
			text-align: center;
		}
		#bottom-img{
			width: 65px;
		}
		#bottom-div{
			margin-top: 90px;
			padding: 0px 78px 0px 78px;
			font-size: 14px;
		}
		#botton-text{
			margin-top: 8px;
		}
		#back{
			margin-top: 20px;
		}
		#img-right{
			margin-left: 18%;
			margin-top: -56px;
			color: #1989FA;
			font-size: 40px;		
		}
		
    </style>
</head>
<body>
	<div id="app">
		<div id="header">
			<div id="img-div">	
				<img src="../img/login-style.png" id="img">						
			</div>
			<div id="img-right">	
				嗨购						
			</div>
			<div id="test-div">				
				<input type="text" name="" id="text" value="" placeholder="请输入账号" v-model="zh"/>
			</div>
			<div id="pws-div">
				<input type="password" name="" id="text" value="" placeholder="请输入密码" v-model="mm"/>
			</div>
			<div id="">				
				<img src="../img/429EC49CFF13792BFD810A267DB464F5.jpg" id="bottom-img" @click="login">
			</div>
			<div id="back">
				<van-row>					
					<van-col span="24" id="botton-text">
						<span @click="back">暂不登录</span>
					</van-col>
				</van-row>
			</div>
			<div id="bottom-div">
				<van-row>
					<van-col span="8">
						<b @click="forgo">忘记密码</b>
					</van-col>
					<van-col span="8">
						<span> 
							|
						</span>
					</van-col>
					<van-col span="8">
						<b @click="register">用户注册</b>
					</van-col>
					<van-col span="24" id="botton-text">
						<span>登录即代表阅读并同意<b>服务条例</b></span>
					</van-col>
				</van-row>
			</div>
			
		</div>
	</div>
	<script type="text/javascript">
		var vm=new Vue({
			el:"#app",
			data:{
				zh: "",
				mm: ""
			},
			methods:{
				login: function() {		//登录按钮
					_this = this;
					if (vm.zh == "") {
						_this.$toast("帐号不能为空");
						return;
					}
					if (vm.mm == "") {
						_this.$toast("帐号不能为空");
						return;
					}
					
					ajax({
						type: "post",
						url: "http://dsapi.ysd3g.com/api/login",
						data: {
							account: vm.zh,
							password: vm.mm
						},
						dataType: "json",
						success: function(res) {								
							if (res.Error == false) {									 
								console.log(res.Key) 
								localStorage.setItem("keys",res.Key); 
								var user=plus.webview.getWebviewById("grzx"); 
								user.reload(true);//刷新主页面
								var name=res.UserData.NickName;
								localStorage.setItem('userData', JSON.stringify(res.UserData));
								localStorage.setItem('imgUrl', res.UserData.AvatarImage);

								localStorage.setItem("name",name);	
								localStorage.setItem("phone",res.UserData.Phone); 									
								var arr=vm.$toast.loading({
									mask: true,	
									duration:0,
									message: '拼命登录中...'
								})
								setTimeout(function(){
									arr;
									var arr=plus.webview.currentWebview();	
									plus.webview.close(arr,"slide-out-right");
								},2000)								
							} else {
								vm.$toast(res.Msg);
							}
						}
					})
				},
				forgo(){		//忘记密码按钮
					plus.webview.create("ForgotPassword.html","forgo");
					plus.webview.show("forgo","slide-in-right");
				},		
				register(){		//注册按钮
					plus.webview.create("register.html","zhuce");
					plus.webview.show("zhuce","slide-in-right");
				},
				back(){
					var arr=plus.webview.currentWebview();
					plus.webview.close(arr,"slide-out-right");
				}
			}
		})
	</script>
</body>
</html>